import type { Schema } from './types';
import SchemaForm from './SchemaItem.tsx';

export default defineComponent({
  props: {
    schema: {
      type: Object as PropType<Schema>,
      required: true,
    },
    value: {
      required: true,
    },
    onChange: {
      type: Function as PropType<(value: any) => void>,
      required: true,
    },
  },
  name: 'SchemaForm',
  setup(props) {
    const handleChange = (v: any) => {
      props.onChange(v);
    };

    return () => {
      const { schema, value } = props;
      return (
        <SchemaForm schema={schema} value={value} onChange={handleChange} />
      );
    };
  },
});
